package com.maben.vue_support.controller;

import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import com.maben.vue_support.constant.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.nio.charset.StandardCharsets;

/**
 * Echart控制类
 */
@RestController
@RequestMapping("echart")
public class EchartController {

    /**
     * 读取文件
     */
    @RequestMapping("getJson")
    public Result getJson(String fileName){
        final File file = new File("./data/"+fileName);
        final String readString = FileUtil.readString(file, StandardCharsets.UTF_8);
        return Result.OK(JSON.parse(readString));
    }

}
